import request from '@/utils/request'
import API from './constants'

//用户登录
export const login = (user) => {
  return request({
    url: '/sessions',
    method: 'POST',
    data: user,
  })
}

// 添加会员信息
export const addUser = user => request({
  url: API.USER_API,
  method: 'POST',
  data:user,
})

// 修改会员信息
export const updateUser = user => request({
  url: API.USER_API + '/' + user.id,
  method: 'PUT',
  data: user,
})

// 删除会员信息
export const removeUser = id => request({
  url: API.USER_API + '/' + id ,
  method: 'DELETE',
})

// 根据条件查询会员
export const findUsers = (condition = {}) => {
  return request({
    url: API.USER_API,
    method: 'GET',
    params: condition,
  })
}
// 根据id查询会员
export const findUsersById = (id) => request ({
  url:API.USER_API+ '/' + id ,
  method: 'GET',
})